import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

import '../http/api.dart';
import '../main.dart';
import '../serial/three_to_one_manager.dart';
import '../util/timer_manager.dart';
class IcrBindDialog{

  ThreeToOneManager manager = ThreeToOneManager();

  icrDialog(){
    tts.speak('请刷身份证');
    manager.setModeAndStart(Mode.identifyBind);
    Get.defaultDialog(
      title: "",
      barrierDismissible: false,
      contentPadding:EdgeInsets.zero,
      titlePadding:EdgeInsets.zero,
      backgroundColor: Colors.transparent,
      content: Container(
        width: 200.w,
        height: 180.h,
        padding: EdgeInsets.all(12.r),
        alignment: AlignmentDirectional.topEnd,
        decoration: const BoxDecoration(
            image: DecorationImage(
              fit: BoxFit.fill,
              image: AssetImage(
                "assets/images/icr_bind_bg.png",
              ),
            )
        ),
        child: InkWell(
          onTap: (){
            manager.setMode(Mode.none);
            Get.back();
          },
          child: Image.asset("assets/images/close.png",width: 10.w,fit: BoxFit.fitWidth,),
        )
      ),
    );
  }



  bindDialog(callback){
    String id = '';
    Get.defaultDialog(
      title: "",
      barrierDismissible: false,
      contentPadding:EdgeInsets.zero,
      titlePadding:EdgeInsets.zero,
      backgroundColor: Colors.transparent,
      content: Container(
        width: 180.w,
        height: 90.h,
        decoration:BoxDecoration(
          color: Colors.white,
          borderRadius: BorderRadius.all(Radius.circular(8.r)),
        ),
        child: Stack(
          alignment: AlignmentDirectional.center,
          children: [
            Positioned(
                top: 8.h,
                right: 12.w,
                child: InkWell(
                  onTap: (){
                    Get.back();
                  },
                  child: Image.asset("assets/images/close.png",width: 10.w,fit: BoxFit.fitWidth,),
                )
            ),

            Positioned(
              top: 6.h,
              child: Text('身份证绑定',style: TextStyle(color:Colors.blue,fontWeight: FontWeight.bold,fontSize: 10.sp),),
            ),
            // Positioned(
            //   top: 45.h,
            //   child:  SizedBox(
            //     width: 140.w,
            //     child: TextField(
            //       keyboardType: TextInputType.number,
            //       decoration:  InputDecoration(
            //         hintText: '请输入真实姓名',
            //         hintStyle: TextStyle(color: Colors.grey,fontSize: 6.sp),
            //         enabledBorder:  OutlineInputBorder(
            //           borderRadius: BorderRadius.all(Radius.circular(16.r)),
            //           borderSide: BorderSide(color: Colors.blue, width: 0.3.w),
            //         ),
            //         focusedBorder: OutlineInputBorder(
            //           borderRadius: BorderRadius.all(Radius.circular(16.r)),
            //           borderSide: BorderSide(color: Colors.blue, width: 0.3.w),
            //         ),
            //         contentPadding: const EdgeInsets.only(left: 5, right: 5, top: 0, bottom: 0).r,
            //       ),
            //       style: TextStyle(fontSize: 8.sp),
            //       onChanged: (value){
            //         _name = value;
            //       },
            //     ),
            //   ),
            // ),
            Positioned(
              top: 30.h,
              child:  SizedBox(
                width: 140.w,
                child: TextField(
                  keyboardType: TextInputType.number,
                  decoration:  InputDecoration(
                    hintText: '请输入身份证号',
                    hintStyle: TextStyle(color: Colors.grey,fontSize: 6.sp),
                    enabledBorder:  OutlineInputBorder(
                      borderRadius: BorderRadius.all(Radius.circular(16.r)),
                      borderSide: BorderSide(color: Colors.blue, width: 0.3.w),
                    ),
                    focusedBorder: OutlineInputBorder(
                      borderRadius: BorderRadius.all(Radius.circular(16.r)),
                      borderSide: BorderSide(color: Colors.blue, width: 0.3.w),
                    ),
                    contentPadding: const EdgeInsets.only(left: 5, right: 5, top: 0, bottom: 0).r,
                  ),
                  style: TextStyle(fontSize: 8.sp),
                  onChanged: (value){
                    id = value;
                  },
                ),
              ),
            ),
            Positioned(
                top: 60.h,
                child: InkWell(
                  onTap: () async {
                    callback(id);
                    Get.back();
                  },
                  child: Image.asset("assets/images/confirm.png",width: 80.w, fit: BoxFit.fitWidth,),
                )
            ),
          ],
        ),
      ),
    );
  }

}